<?php

$params = require(__DIR__ . '/params.php');
$db = require(__DIR__ . '/db.php');

$config = [
    'id' => 'basic',
    'basePath' => dirname(__DIR__),
    'language' => 'zh-CN',
    'charset' => 'UTF-8',
    'bootstrap' => ['log'],
    'modules' => [
        'debug' => 'yii\debug\Module',
        'gii' => 'yii\gii\Module',
    ],
    'vendorPath' => dirname(__DIR__) . '/vendor',
    'timeZone' => 'Asia/Shanghai',
    'runtimePath'=>'/data/runtime/',
    'components' => [
        'request' => [
            'cookieValidationKey'   => '83r5HbITBiMfmiYPOZFdL-raVp4O1VV4',
            'enableCookieValidation' => false, // 取消cooke 验证
            'enableCsrfValidation' => false
        ],
        'assetManager' => [
            'appendTimestamp' => true,
            'linkAssets' => true,
            'basePath' => '@webroot/assets',
            'baseUrl' => '@web/assets',
            'bundles'=>[
                'yii\web\JqueryAsset'=>[
                    'jsOptions'=>[
                        'position'=>\yii\web\View::POS_HEAD,
                    ]
                ]
            ]
        ],
        'cache' => [
            'class' => 'yii\caching\FileCache',
        ],
        'user' => [
            'identityClass' => 'app\models\User',
            'enableAutoLogin' => true,
        ],
        'errorHandler' => [
            'errorAction' => 'site/error',
        ],
        'mailer' => [
            'class' => 'yii\swiftmailer\Mailer',
            // send all mails to a file by default. You have to set
            // 'useFileTransport' to false and configure a transport
            // for the mailer to send real emails.
            'useFileTransport' => true,
        ],
        'log' => [
            'traceLevel' => YII_DEBUG ? 3 : 0,
            'flushInterval'=>1,
            'targets' => [
                'application'=>[
                    'class' => 'app\common\log\ApplicationTarget',
                    'levels' => ['info'],
                    'categories' => ['application'],
                    // 文件最大10g
                    'maxFileSize' => 10240000,
                ]
            ],
        ],
        'db' => $db,
        'session' => [
            'class' => 'yii\web\DbSession',
//            'db' => 'mydb',  // 数据库连接的应用组件ID，默认为'db'.
            'sessionTable' => '{{%session}}', // session 数据表名，默认为'session'.
        ],
        'urlManager' => [
            'enablePrettyUrl' => 'true',
            'showScriptName' => false, //去除index.php
            'rules' => []
        ],
    ],
    'params' => $params,
];

if (YII_ENV_DEV) {
    // configuration adjustments for 'dev' environment
//    $config['bootstrap'][] = 'debug';
//    $config['modules']['debug'] = [
//        'class' => 'yii\debug\Module',
//        // uncomment the following to add your IP if you are not connecting from localhost.
//        'allowedIPs' => ['127.0.0.1', '::1'],
//    ];

    $config['bootstrap'][] = 'gii';
    $config['modules']['gii'] = [
        'class' => 'yii\gii\Module',
        // uncomment the following to add your IP if you are not connecting from localhost.
        'allowedIPs' => ['127.0.0.1', '::1'],
    ];
}

return $config;
